import json

str = '{"flag":"少儿编程"}'
print(type(str),":",str)
obj = json.loads(str)#从json对象转为python对象
print(type(obj), ":", obj)
str2 = json.dumps(obj, ensure_ascii=False)#从python对象转为json字符串
print(type(str2), ":", str2)
#json.dump（）将python序列化为json对象写入文件
json.dump(obj,open('childprogramming.txt','w',encoding='utf-8'),ensure_ascii=False)
#json.load（）将json字符串序列化为python类型
str3=json.load(open('childprogramming.txt',encoding='utf-8'))
print(str3)